home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / FredFish PD 315.adf / Surf / menu_files.c < prev    next >
C/C++ Source or Header  |  1990-02-14  |  8KB  |  265 lines

  1. #include "gadgetdef.h"
  2.  
  3. static struct IntuiText filetext[] = {
  4.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"save as", NULL },
  5.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"save first", NULL },
  6.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"save next", NULL },
  7.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"open map", NULL },
  8.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"close map", NULL },
  9.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"write data", NULL }
  10. };
  11.  
  12. static struct IntuiText greytext[] = {
  13.    { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"Grey model",   NULL },
  14.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"Average",   NULL },
  15.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"Lumin",   NULL },
  16.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"Distance",   NULL },
  17.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"R only",   NULL },
  18.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"G only",   NULL },
  19.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"B only",   NULL }
  20. };
  21.  
  22. static struct IntuiText packtext[] = {
  23.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"compression", NULL },
  24.     { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"run length", NULL },
  25.     { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"none", NULL }
  26. };
  27.  
  28.  
  29.  
  30. #define FILEFLAGS  ( ITEMTEXT | HIGHCOMP | ITEMENABLED )
  31.  
  32. static struct MenuItem packitems[] = {
  33.   { &packitems[1], /* next item */
  34.     90, 0, 110 , 10, /* x,y,w,h */
  35.     COLMEMFLAGS| CHECKED,
  36.     2, /* mutual exclude bits */
  37.     (APTR) &packtext[1],  /* grey */
  38.     NULL, /* highlight image */
  39.     'h', /* command byte ? */
  40.     NULL, /* submenu item */
  41.     0 /* next select for select dragging */
  42.     },
  43.   { NULL, /* next item */
  44.     90, 10, 110 , 10, /* x,y,w,h */
  45.     COLMEMFLAGS,
  46.     1, /* mutual exclude bits */
  47.     (APTR) &packtext[2],  /* grey */
  48.     NULL, /* highlight image */
  49.     'h', /* command byte ? */
  50.     NULL, /* submenu item */
  51.     0 /* next select for select dragging */
  52.     }
  53. };
  54.  
  55. #define GREYMUTUAL(pos) (077 ^ (1<<(pos)))
  56. static struct MenuItem greyitems[] = {
  57.   { &greyitems[1], /* next item */
  58.     90, 0, 80 , 10, /* x,y,w,h */
  59.     COLMEMFLAGS|CHECKED,
  60.     GREYMUTUAL(0), /* mutual exclude bits */
  61.     (APTR) &greytext[1],  /* average */
  62.     NULL, /* highlight image */
  63.     'h', /* command byte ? */
  64.     NULL, /* submenu item */
  65.     0 /* next select for select dragging */
  66.     },
  67.   { &greyitems[2], /* next item */
  68.     90, 10, 80 , 10, /* x,y,w,h */
  69.     COLMEMFLAGS,
  70.     GREYMUTUAL(1), /* mutual exclude bits */
  71.     (APTR) &greytext[2],  /* lumin */
  72.     NULL, /* highlight image */
  73.     'h', /* command byte ? */
  74.     NULL, /* submenu item */
  75.     0 /* next select for select dragging */
  76.     },
  77.   { &greyitems[3], /* next item */
  78.     90, 20, 80 , 10, /* x,y,w,h */
  79.     COLMEMFLAGS,
  80.     GREYMUTUAL(2), /* mutual exclude bits */
  81.     (APTR) &greytext[3],  /* dist */
  82.     NULL, /* highlight image */
  83.     'h', /* command byte ? */
  84.     NULL, /* submenu item */
  85.     0 /* next select for select dragging */
  86.     },
  87.   { &greyitems[4], /* next item */
  88.     90, 30, 80 , 10, /* x,y,w,h */
  89.     COLMEMFLAGS,
  90.     GREYMUTUAL(3), /* mutual exclude bits */
  91.     (APTR) &greytext[4],  /* dist */
  92.     NULL, /* highlight image */
  93.     'h', /* command byte ? */
  94.     NULL, /* submenu item */
  95.     0 /* next select for select dragging */
  96.     },
  97.   { &greyitems[5], /* next item */
  98.     90, 40, 80 , 10, /* x,y,w,h */
  99.     COLMEMFLAGS,
  100.     GREYMUTUAL(4), /* mutual exclude bits */
  101.     (APTR) &greytext[5],  /* dist */
  102.     NULL, /* highlight image */
  103.     'h', /* command byte ? */
  104.     NULL, /* submenu item */
  105.     0 /* next select for select dragging */
  106.     },
  107.   { NULL, /* next item */
  108.     90, 50, 80 , 10, /* x,y,w,h */
  109.     COLMEMFLAGS,
  110.     GREYMUTUAL(5), /* mutual exclude bits */
  111.     (APTR) &greytext[6],  /* dist */
  112.     NULL, /* highlight image */
  113.     'h', /* command byte ? */
  114.     NULL, /* submenu item */
  115.     0 /* next select for select dragging */
  116.     }
  117. };
  118.  
  119.  
  120.  
  121.  
  122. static struct MenuItem fileitems[] = {
  123.   { &fileitems[1], /* next item */
  124.     10, 0, 90 , 10, /* x,y,w,h */
  125.     FILEFLAGS,
  126.     0, /* mutual exclude bits */
  127.     (APTR) &filetext[0],  /* grey */
  128.     NULL, /* highlight image */
  129.     'h', /* command byte ? */
  130.     NULL, /* submenu item */
  131.     0 /* next select for select dragging */
  132.     },
  133.   { &fileitems[2], /* next item */
  134.     10, 10, 90 , 10, /* x,y,w,h */
  135.     FILEFLAGS,
  136.     0, /* mutual exclude bits */
  137.     (APTR) &filetext[1],  /* grey */
  138.     NULL, /* highlight image */
  139.     'h', /* command byte ? */
  140.     NULL, /* submenu item */
  141.     0 /* next select for select dragging */
  142.     },
  143.   { &fileitems[3], /* next item */
  144.     10, 20, 90 , 10, /* x,y,w,h */
  145.     FILEFLAGS,
  146.     0, /* mutual exclude bits */
  147.     (APTR) &filetext[2],  /* grey */
  148.     NULL, /* highlight image */
  149.     'h', /* command byte ? */
  150.     NULL, /* submenu item */
  151.     0 /* next select for select dragging */
  152.     },
  153.   { &fileitems[4], /* next item */
  154.     10, 30, 90 , 10, /* x,y,w,h */
  155.     FILEFLAGS,
  156.     0, /* mutual exclude bits */
  157.     (APTR) &packtext[0],  /* grey */
  158.     NULL, /* highlight image */
  159.     'h', /* command byte ? */
  160.     packitems, /* submenu item */
  161.     0 /* next select for select dragging */
  162.     },
  163.   { &fileitems[5], /* next item */
  164.     10, 40, 90 , 10, /* x,y,w,h */
  165.     FILEFLAGS,
  166.     0, /* mutual exclude bits */
  167.     (APTR) &filetext[3],  /* grey */
  168.     NULL, /* highlight image */
  169.     'h', /* command byte ? */
  170.     NULL, /* submenu item */
  171.     0 /* next select for select dragging */
  172.     },
  173.   { &fileitems[6], /* next item */
  174.     10, 50, IMAGE_HITWIDTH , 10, /* x,y,w,h */
  175.     COLMEMFLAGS,
  176.     1, /* mutual exclude bits */
  177.     (APTR) &greytext[0],     /* red */
  178.     NULL, /* highlight image */
  179.     'h', /* command byte ? */
  180.     greyitems, /* submenu item */
  181.     0 /* next select for select dragging */
  182.     },
  183.   { &fileitems[7], /* next item */
  184.     10, 60, 90 , 10, /* x,y,w,h */
  185.     FILEFLAGS,
  186.     0, /* mutual exclude bits */
  187.     (APTR) &filetext[4],  /* grey */
  188.     NULL, /* highlight image */
  189.     'h', /* command byte ? */
  190.     NULL, /* submenu item */
  191.     0 /* next select for select dragging */
  192.     },
  193.   { NULL, /* next item */
  194.     10, 70, 90 , 10, /* x,y,w,h */
  195.     FILEFLAGS,
  196.     0, /* mutual exclude bits */
  197.     (APTR) &filetext[5],  /* grey */
  198.     NULL, /* highlight image */
  199.     'h', /* command byte ? */
  200.     NULL, /* submenu item */
  201.     0 /* next select for select dragging */
  202.     }
  203. };
  204.  
  205. extern char *GetOutFile();
  206. extern char *GetInFile();
  207.  
  208. MenuDoFile(item)
  209. int item;
  210. {
  211.     static int filecnt = 0;
  212.     char tempbuff[80];
  213.     char *filename;
  214.     bool packflag;
  215.     int i;
  216.  
  217.     packflag = Selected( packitems[0] )?1:0;
  218.  
  219.  
  220.     switch (item ) {
  221.     case 0:
  222.         if( (filename = GetOutFile())) {
  223.             SetHourGlass();
  224.             WriteIlbm(filename, &SurfWinDef, &SurfScrnDef, packflag);
  225.         }
  226.         break;
  227.     case 1:
  228.         filecnt = 0; /* deliberate fall into case 2 */
  229.     case 2:
  230.         if( filename = GetOutFile()) {
  231.             SetHourGlass();
  232.             sprintf(tempbuff, "%s.%d", filename, filecnt++ );
  233.             WriteIlbm(tempbuff, &SurfWinDef, &SurfScrnDef, packflag);
  234.         }
  235.         break;
  236.     case 4:
  237.         if( filename = GetInFile()){
  238.             SetHourGlass();
  239.             ReadIlbm( filename);
  240.         }
  241.         break;
  242.     case 5:
  243.         for( i = 0; i < (sizeof(greyitems)/sizeof(greyitems[0])); i++ ) {
  244.             if( Selected(greyitems[i])) {
  245.                 SetGreyModel(i);
  246.             }
  247.         }
  248.         break;
  249.     case 6:
  250.         CloseImgPix();
  251.         break;
  252.     case 7:
  253.         if( filename = GetOutFile()) {
  254.             SetHourGlass();
  255.             WriteData(filename);
  256.         }
  257.         break;
  258.  
  259.     default:
  260.         break;
  261.     }
  262.  
  263.     ClearHourGlass();
  264. }
  265.